package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.erp.R
import com.erp.module.scanBaomingxi.baomingxiBean
import com.erp.util.Myutil
import com.erp.util.Sputil
import kotlinx.android.synthetic.main.lv_tv_scanbaomingxi.view.*

class BaomingxiRvAdapter(private val mlist: List<baomingxiBean>, private val mcontext: Context) : RecyclerView.Adapter<BaomingxiRvAdapter.ViewHolder>() {
    internal var width = 0
    init {
        width = Sputil.sp("erp").getInt("width", width)
    }

    override fun onCreateViewHolder(parent: ViewGroup, p1: Int): BaomingxiRvAdapter.ViewHolder {
        val view: View = LayoutInflater.from(parent.getContext()).inflate(R.layout.lv_tv_scanbaomingxi, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mlist.size
    }

    override fun onBindViewHolder(h: BaomingxiRvAdapter.ViewHolder, position: Int) {
        var bean = mlist[position]
        Myutil.settv(bean.name,h.tv_name)
        Myutil.settv(bean.guige,h.tv_guige)
        Myutil.settv(bean.count,h.tv_shuliang)

    }

    class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        var tv_name : TextView
        var tv_guige : TextView
        var tv_shuliang : TextView
        init {
            tv_name = view.tv_name
            tv_guige = view.tv_guige
            tv_shuliang = view.tv_shuliang
        }
    }
}